﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
namespace BLL.Sec
{
    /// <summary>
    /// 操作权限类，每个权限抽象为一个实例
    /// </summary>
    public class Operate
    {
        private readonly OracleDAL.Sec.Operate dal = new OracleDAL.Sec.Operate();
        /// <summary>
        /// 操作权限类构造函数
        /// </summary>
        public Operate()
        {

        }
        /// <summary>
        /// 获取操作权限根节点
        /// </summary>
        /// <returns>根操作权限的集合</returns>
        public Model.Sec.OperateCollection GetRootOperates(string UserISN)
        {
            return this.GetChildOperates(null, UserISN);
        }
        /// <summary>
        /// 获取指定操作权限的子权限集合(集合中有两部分：用户有权限操作的菜单权限、用户没权限操作的按钮权限)
        /// </summary>
        /// <param name="ParentTreeOrder">父节点TreeOrder,为null时返回操作权限根节点</param>
        /// <param name="UserISN">用户ISN</param>
        public Model.Sec.OperateCollection GetChildOperates(string ParentTreeOrder, string UserISN)
        {
            return dal.GetChildOperates(ParentTreeOrder, UserISN);
        }
        /// <summary>
        /// 删除菜单项，并删除相关用户组的权限
        /// </summary>
        /// <param name="TREEORDER"></param>

        /// <returns></returns>
        public bool delOperateMenu(string TREEORDER)
        {
            return dal.delOperateMenu(TREEORDER);
        }
        /// <summary>
        /// 判断是否存在
        /// </summary>
        /// <param name="strwhere"></param>
        /// <returns></returns>
        public bool ISExist(string strwhere)
        {
            return dal.ISExist(strwhere);
        }
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool Update(Model.Sec.Operate model)
        {
            return dal.Update(model);
        }
        /// <summary>
        /// 更新相似的treeorder
        /// </summary>
        /// <returns></returns>
        public bool updateRelate(string OldTreeOrder, string NewTreeOrder)
        {
            return dal.updateRelate(OldTreeOrder, NewTreeOrder);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="strWhere"></param>
        /// <returns></returns>
        public Model.Sec.Operate getModel(string strWhere)
        {
            return dal.getModel(strWhere);
        }

        /// <summary>
        /// 因为返回的最大的treeOrder,参数treeOrder="0"时，返回第一层最大的treeOrder
        /// </summary>
        /// <param name="treeOrder"></param>
        /// <returns></returns>
        public string getMaxTreeOrder(string treeOrder)
        {
            return dal.getMaxTreeOrder(treeOrder);
        }
        /// <summary>
        /// 上下移动节点
        /// </summary>
        /// <param name="UptreeOrder">原来在上面的节点treeOrder</param>
        /// <param name="UpOperateID">原来在上面的节点OperateID</param>
        /// <param name="DownTreeOrder">原来在下面的节点treeOrder</param>
        /// <param name="DownOperateID">原来在下面的节点OperateID</param>
        /// <returns></returns>
        public bool UPDownMove(string UptreeOrder, string UpOperateID, string DownTreeOrder, string DownOperateID)
        {
            return dal.UPDownMove(UptreeOrder, UpOperateID, DownTreeOrder, DownOperateID);
        }
        /// <summary>
        /// 增加
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool add(Model.Sec.Operate model)
        {

            return dal.add(model);
        }
        /// <summary>
        /// 根据OperateID查找下一级的Operate
        /// </summary>
        /// <param name="OperateID"></param>
        /// <returns></returns>
        public DataTable returnTable(string OperateID)
        {
            return dal.returnTable(OperateID);
        }
        /// <summary>
        /// 修改节点时用
        /// </summary>
        /// <param name="TreeOrder"></param>
        /// <param name="OperateName"></param>
        /// <param name="TreeUrl"></param>
        /// <param name="operateID"></param>
        /// <returns></returns>
        public bool Update(string TreeOrder, string OperateName, string TreeUrl, string operateID)
        {
            return dal.Update(TreeOrder, OperateName, TreeUrl, operateID);
        }
        /// <summary>
        /// 根据TreeOrder返回所有同级的TreeOrder
        /// </summary>
        /// <param name="treeOrder"></param>
        /// <returns></returns>
        public DataTable getAllOperateID(string treeOrder)
        {
            return dal.getAllOperateID(treeOrder);
        }
        /// <summary>
        /// 根据父OperateID查找下一级子OperateID，子OperateID以,号分开
        /// </summary>
        /// <param name="ParentOperateID"></param>
        /// <returns></returns>
        public string getChildOperateID(string ParentOperateID)
        {
            return dal.getChildOperateID(ParentOperateID);
        }
        /// <summary>
        /// 获取所有的通用标识符
        /// </summary>
        /// <returns></returns>
        public DataTable getAllCommon()
        {
            return dal.getAllCommon();
        }
        /// <summary>
        /// 根据用户ID获取可以访问的网系ID，返回形式为,11,23,232,......,
        /// </summary>
        /// <param name="userGroup">用户所属用户组，形式为'test','wei'</param>
        /// <returns></returns>
        public string getNetID(string userGroup)
        {
            return dal.getNetID(userGroup);
        }
        /// <summary>
        /// 根据用户组查找下一级的权限OperateID
        /// </summary>
        /// <param name="usergroupISNs">用户组，形式为'roots','87'</param>
        /// <param name="ParentOperateID">父页面的OPerateID</param>
        /// <returns></returns>
        public DataTable GetOperateIDByUserGroupISN(string usergroupISNs, string ParentOperateID)
        {
            return dal.GetOperateIDByUserGroupISN(usergroupISNs, ParentOperateID);
        }
    }
}
